#include<cstring>
#include"scorenum.h"
#include<iostream>


scoreNum::scoreNum()
{
    QString str;
    dirOfpic[0]=":/new/prefix1/flappybird/font_048.png";
    dirOfpic[1]=":/new/prefix1/flappybird/font_049.png";
    dirOfpic[2]=":/new/prefix1/flappybird/font_050.png";
    dirOfpic[3]=":/new/prefix1/flappybird/font_051.png";
    dirOfpic[4]=":/new/prefix1/flappybird/font_052.png";
    dirOfpic[5]=":/new/prefix1/flappybird/font_053.png";
    dirOfpic[6]=":/new/prefix1/flappybird/font_054.png";
    dirOfpic[7]=":/new/prefix1/flappybird/font_055.png";
    dirOfpic[8]=":/new/prefix1/flappybird/font_056.png";
    dirOfpic[9]=":/new/prefix1/flappybird/font_057.png";
    data=0;
    num[0]=0;num[1]=0;num[2]=0;num[3]=0;
    isPaint=false;
    digit=0;
}

void scoreNum::setScore(int a)
{
    data= a;
    int k=0;
    while(data)
    {

        int temp=data%10;
        data/=10;
        num[k]=temp;
        k++;
    }
    k--;
    digit=k;
    for(int i=0;k>=0;k--,i++)
    {
      image[i].load(dirOfpic[num[k]]);
      rect[i] =  QRect (380+i*25,50,24,44);
    }


}



QRect scoreNum::getRect(int k)
{

    return  rect[k];

}

QImage &scoreNum::getImage(int k)
{
     return image[k];
}

int scoreNum::getDigit()
{
    return digit;
}

QImage &scoreNum::getZero()
{
    image[0].load(dirOfpic[num[0]]);
    return  image[0];
}
